﻿$(document).ajaxStop($.unblockUI);

$("#job_application_submit").click(
  function () {
      var validator = $("#job_application_form").bind("invalid-form.validate", function () {
          
      }).validate({
          debug: true,
          errorElement: "em",
          errorPlacement: function(error, element) {
              error.appendTo(element.prev());
          },
          success: function(label) {
              
          },
          rules: {
              job_application_email: {
                  required: true,
                  email: true,
                  minlength: 7
              },
              job_application_name: {
                  required: true,
                  minlength: 6
              },
              job_application_telephone: {
                  required: true,
                  minlength: 6
              },
              job_application_comment: {
                  required: true,
                  minlength: 6
              }
          },
          messages: {
          },
          submitHandler: function(form) {
              $.blockUI({ message: lm });
              AstroRecruitment.JobApply(al);
          }
      });
  });

  $("#send_to_friend_submit").click(
  function () {
      var validator = $("#send_friend_form").bind("invalid-form.validate", function () {

      }).validate({
          debug: true,
          errorElement: "em",
          errorPlacement: function (error, element) {
              error.appendTo(element.prev());
          },
          success: function (label) {

          },
          rules: {
              send_to_friend_from_email: {
                  required: true,
                  email: true,
                  minlength: 7
              },
              send_to_friend_to_email: {
                  required: true,
                  email: true,
                  minlength: 7
              },
              send_to_friend_comment: {
                  required: true,
                  minlength: 6
              }
          },
          messages: {
          },
          submitHandler: function (form) {
              $.blockUI({ message: lm });
              AstroRecruitment.EmailFriend(al);
          }
      });
  });

  $("#job_reference_submit").click(
  function () {
      var validator = $("#refer_friend_form").bind("invalid-form.validate", function () {

      }).validate({
          debug: true,
          errorElement: "em",
          errorPlacement: function (error, element) {
              error.appendTo(element.prev());
          },
          success: function (label) {

          },
          rules: {
              job_reference_email: {
                  required: true,
                  email: true,
                  minlength: 7
              },
              job_reference_name: {
                  required: true,
                  minlength: 6
              },
              job_reference_telephone: {
                  required: true,
                  minlength: 6
              },
              job_reference_comment: {
                  required: true,
                  minlength: 6
              }
          },
          messages: {
          },
          submitHandler: function (form) {
              $.blockUI({ message: lm });
              AstroRecruitment.ReferFriend(al);
          }
      });
  });

  var al = '/__utility/ajax/candidate.ashx';
  var lm = "<h2><img class='busyprocess' src='/files/themes/Astro/images/busy.gif'>Loading...</h2>";